package com.youlai.boot.weather.controller;

import com.youlai.boot.common.result.Result;
import com.youlai.boot.common.util.WeatherUtil;
import com.youlai.boot.weather.model.Location;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 用户每周运动时常计划前端控制层
 *
 * @author cuisheng
 * @since 2025-04-01 10:39
 */
@Tag(name = "天气接口")
@RestController
@RequestMapping("/api/v1/weather")
@RequiredArgsConstructor
public class WeatherController {
    @Operation(summary = "获取天气")
    @GetMapping
    public Result<Object> getUserWeekPlanPage(Location location) {
        try {
            return Result.success(WeatherUtil.getWeather(location));
        }catch (Exception e) {
            throw new RuntimeException("天气获取异常");
        }
    }
}
